<template>
    <div>
        <h2>首頁</h2>   
        <p>欢迎您,老师！</p>
    <h1>学生信息录入</h1>
    <p>学生姓名：<input type="text" v-model="username"></p>
    <p>学生年龄：<input type="text" v-model="age"></p>
    <button @click="sub1()">提交</button>
    <p @click="sub2(id)">点击查看您班级的学生</p>
    <p @click="sub3()">点击查看未分班级的学生</p>
    </div>    
</template>

<script>
import axios from "axios"
export default {
    name:"fristpage",
    data() {
        return {
        //    str:"",
           username:"",
           age:"", 
        }
    },
    methods:{
        sub1(){
            let formdata = new FormData()
            formdata.append("name",this.username)
            formdata.append("age",this.age)
            // formdata.append("cate",1)
            axios({
                url:"http://127.0.0.1:8000/app03/student/",
                method:"post",
                data:formdata
            }).then(res=>{
                console.log(res.data)
            })
        },
        sub2(id){
            // var data={"id":this.id}
            localStorage.getItem('id',id);
            this.$router.push({path:"/student/"+id})

        },
        sub3(){
            this.$router.push({name:"student2"})
        }
    }
}
</script>

<style>

</style>
